define(function (require) {
    'use strict';
    var environment = require('environment');
    var util = require('util');
    require('permission');
    require('global');
    var token = util.getToken();
    var userInfo = require('authorize').getUserInfo();
    var loginOrgName = userInfo.orgCode || util.getCookie('loginOrgName');
    var ydxsbghostname = environment.ydxs;

    function getUrl(name,orgName,path,token){
        return name +'/' + orgName + path + token;
    }

    function getRedirect(code){
        return environment.qmyx + '/api/index.php?r=site/redirect-to&token=' + token + '&page=' + code;
    }
    var codeMap = {
        tkTeam : getUrl(ydxsbghostname, loginOrgName,'/admin/tfansadmin/tuser/index?token=',token),//拓客团队管理
        cst_assign : getRedirect('cst_assign'),//客户分配
        building_source : getRedirect('building_source'),//房源管理
        paramsSetting : getRedirect('paramsSetting'),//参数设置
        erpi_nterface_set : getRedirect('erpi_nterface_set'),//ERP接口配置
        sales_data_init : getUrl(ydxsbghostname , loginOrgName , '/admin/init/erp-data-init/index?token=' , token),//数据初始化
        custom_page : getUrl(ydxsbghostname , loginOrgName , '/admin/init/custom-page/index?token=' , token),//定制页面
        daily_report : getRedirect('daily_report'),//案场日报
        performance_report : getRedirect('performance_report'),//销售业绩
        cstSyncExcep : getUrl(ydxsbghostname , loginOrgName , '/admin/sales/customer/cst-sync-failed-list?token=' , token)//客户同步监控
    };
    function getUrlByCode(code){
        if(!code){
            code = util.getUrlPara('code');
        }
        var mapped = codeMap[code];
        return mapped;
    }

    util.nestIframe('#page_iframe_wrapper', getUrlByCode(), 850);
});
